package com.future;

import com.future.util.TreeNode;

/**
 * Description: 404. 左叶子之和
 *
 * @author weiruibai.vendor
 * Date: 2023/1/9 14:31
 */
public class Solution_404 {

    public int sumOfLeftLeaves(TreeNode root) {
        calLeftLeavesSum(root);
        return ans;
    }

    private void calLeftLeavesSum(TreeNode root) {
        if (root == null) {
            return;
        }
        if (root.left != null && root.left.left == null && root.left.right == null) {
            ans += root.left.val;
        }
        calLeftLeavesSum(root.left);
        calLeftLeavesSum(root.right);
    }
    int ans = 0;
}
